package com.hmkj.core.model.order;

import com.hmkj.core.po.order.Order;
import com.hmkj.core.po.user.User;
import lombok.Data;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Data
public class OrderModel extends Order {

    private User u;

    private User i;

    /**
     * 浮动盈亏
     */
    private BigDecimal currentProfit;
    /**
     * 盈亏
     */
    private String profit;
    /**
     * 最新价
     */
    private String lastPrice;
    /**
     * 交易分配
     */
    private String tradeProfit;
    /**
     * 邀请人姓名
     */
    private String inviterName;

    /**
     * 用户Id
     */
    private Integer userId;

    /**
     * 点买总额
     */
    private BigDecimal sumTradeCredit;

    /**
     * 未支付递延费总额
     */
    private BigDecimal sumUnpaidDiYan;


    public static boolean checkTradeDate() throws ParseException {
        Calendar c = Calendar.getInstance();
        if (c.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            return false;
        }
        Date da = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        String now = sdf.format(da);
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        Calendar c3 = Calendar.getInstance();
        Calendar c4 = Calendar.getInstance();
        Calendar c5 = Calendar.getInstance();
        c1.setTime(sdf.parse("09:30:00"));
        c2.setTime(sdf.parse("14:55:00"));
        c3.setTime(sdf.parse(now));
        c4.setTime(sdf.parse("11:30:00"));
        c5.setTime(sdf.parse("13:00:00"));
        if (!(c3.compareTo(c1) > 0 && c3.compareTo(c4) < 0) && !(c3.compareTo(c5) > 0 && c3.compareTo(c2) < 0)) {
            return false;
        }
        return true;
    }
}
